// 玩家数据管理
import PlayerInfo from './../../Communal/PlayerInfo'

let PlayerData = function() {
    let that = {};
    // 手上的牌
    // that.info = [];
    // that.info1 = [];
    // that.info2 = [];
    // that.info3 = [];
    that.info = [0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x11,0x12,0x13,0x14,0x14];    // 例子->测试使用
    that.info1 = [0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01]; 
    that.info2 = [0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01];
    that.info3 = [0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01];

    // 摇色子的玩家
    that.PalyerDice = 0;

    // 色子点数
    that.PalyerDicePoint = 2;

    // 发牌的显示牌堆
    that.Palyer0PaiDui = [];                  // 自己的显示牌堆
    // that.Palyer1PaiDui = [];
    // that.Palyer2PaiDui = [];
    // that.Palyer3PaiDui = [];
    that.Palyer1PaiDui = [0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x11,0x12,0x13,0x14,0x14]; // 例子->测试使用
    that.Palyer2PaiDui = [0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x11,0x12,0x13,0x14,0x14];
    that.Palyer3PaiDui = [0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x11,0x12,0x13,0x14,0x14];

    // 背面牌堆
    that.PaiDuiPlayrID = 0;                 // 玩家背面牌堆的ID
    that.PaiDuiCardNum = 0;                 // 背面牌堆的数量
    that.KaiShiTakePlayrID = 0;             // 拿牌玩家背面牌堆的ID
    that.KaiShiTakeCardID = 0;              // 拿牌的位置

    that.GAME_PLAYER = 4;                   // 游戏人数
    that.MyChairID = 2;                     // 椅子索引（自己的椅子ID）

    that.PlayerInfo = [];
    
    // 创建玩家
    that.CreatorPlayer = function(){
        for(var num=0; num < this.GAME_PLAYER ; ++num){
            var player = new PlayerInfo();
            this.PlayerInfo.push(player);
        }
    }

    // 换算座位号
    // chairID                          座位ID
    that.SwitchViewChairID = function(chairID){
        return ((chairID - this.MyChairID + this.GAME_PLAYER) % this.GAME_PLAYER);
    };

    

    return that;
};
export default PlayerData;